import { useRef } from 'react'

const useObject = <T>(creator: () => T) => {
  const objRef = useRef<T | null>(null)
  if (!objRef.current!)
    objRef.current = creator()

  return objRef.current!
}
export default useObject
